import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:tender_flutter/constant/resource_path.dart';
import 'package:tender_flutter/constant/theme_colors.dart';
import 'package:tender_flutter/router/router.dart';
import 'package:tender_flutter/router/router_map.gr.dart';
import 'package:tender_flutter/utils/screen_adaper.dart';

/// 置顶
final int PLACE_DIALOG_TOP = 1;

/// 免费发布
final int PLACE_DIALOG_FREE = 2;

/// 关闭
final int PLACE_DIALOG_CLOSE = 3;

class PlaceTopDialog extends StatefulWidget {
  @override
  _PlaceTopDialogState createState() => _PlaceTopDialogState();
}

class _PlaceTopDialogState extends State<PlaceTopDialog> {
  @override
  Widget build(BuildContext context) {
    return _initBody();
  }

  Widget _initBody() {
    return Scaffold(
        backgroundColor: Colors.transparent,
        body: Center(
            child: Container(
          width: ScreenAdapter.width(650),
          child: Column(mainAxisSize: MainAxisSize.min, children: [
            Align(
              alignment: Alignment.topRight,
              child: IconButton(
                  onPressed: () {
                    LRouter.navigatorCtx(context).pop(PLACE_DIALOG_CLOSE);
                  },
                  icon: Image.asset(
                    RPath.imgPath + "icon_dialog_close.png",
                    fit: BoxFit.contain,
                    width: ScreenAdapter.width(60),
                    height: ScreenAdapter.width(60),
                  )),
            ),
            Container(
              height: ScreenAdapter.height(500),
              //设置背景图片
              decoration: new BoxDecoration(
                image: DecorationImage(
                  fit: BoxFit.cover,
                  image:
                      ExactAssetImage(RPath.imgPath + "img_place_top_bg.png"),
                ),
              ),
              child: Stack(
                alignment: Alignment.center,
                children: [
                  Column(children: [
                    SizedBox(height: ScreenAdapter.height(130)),
                    Text(
                      "置顶加入可优先展示",
                      style: TextStyle(
                          color: ThemeColors.colorType24,
                          fontSize: ScreenAdapter.sp(36),
                          fontWeight: FontWeight.bold),
                    ),
                    SizedBox(height: ScreenAdapter.height(30)),
                    Text(
                      "开通VIP可享受更多权益",
                      style: TextStyle(
                          color: ThemeColors.colorType16,
                          fontSize: ScreenAdapter.sp(36),
                          fontWeight: FontWeight.bold),
                    ),
                  ]),
                  Align(
                      alignment: Alignment.bottomCenter,
                      child: Container(
                          height: ScreenAdapter.height(87),
                          margin:
                              EdgeInsets.only(bottom: ScreenAdapter.height(40)),
                          padding: EdgeInsets.symmetric(
                              horizontal: ScreenAdapter.width(40)),
                          child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Expanded(
                                    flex: 3,
                                    child: FlatButton(
                                        onPressed: () {
                                          LRouter.navigatorCtx(context)
                                              .pop(PLACE_DIALOG_TOP);
                                        },
                                        height: double.infinity,
                                        color: ThemeColors.colorWhite,
                                        child: Text("立即置顶",
                                            style: TextStyle(
                                                color: ThemeColors.colorType6,
                                                fontSize:
                                                    ScreenAdapter.sp(32))))),
                                Expanded(flex: 1, child: SizedBox()),
                                // Expanded(child: SizedBox()),
                                Expanded(
                                    flex: 3,
                                    child: FlatButton(
                                        onPressed: () {
                                          Navigator.pop(context, "开通VIP");
                                          LRouter.navigatorCtx(context)
                                              .push(Routes.memberCentrePage);
                                        },
                                        height: double.infinity,
                                        color: ThemeColors.colorType43,
                                        child: Text(
                                          "开通VIP",
                                          style: TextStyle(
                                              color: ThemeColors.colorType44,
                                              fontSize: ScreenAdapter.sp(32)),
                                        ))),
                              ])))
                ],
              ),
            ),
            FlatButton(
                onPressed: () {
                  LRouter.navigatorCtx(context).pop(PLACE_DIALOG_FREE);
                },
                child: Text(
                  "免费加入",
                  style: TextStyle(
                      color: ThemeColors.colorWhite,
                      fontSize: ScreenAdapter.sp(32)),
                )),
          ]),
        )));
  }
}
